#include <iostream>
#include <vector>

using namespace std;

void merge_sort(vector<int> &vec)
{
    int len = vec.size();
    vector<int> vecTemp(len); //创建临时数组

    for(int seg = 1; seg < len; seg += seg) //指定步长，从开始的1，到2,4,6...到len-1;
                                            //对不同步长的数开始比较排序，最开始是对步长为1的两个数排序，下来是步长为2的4个数，步长为4的8个数...
    {
        //对同一步长的不同数组开始排序
        for(int start = 0; start < len; start += seg + seg) 
        {
            int index = start; //定义临时数组的下标
            int start1 = start;
            int end1 = min(start + seg,len);
            int start2 = min(start + seg,len); //需取较小值
            int end2 = min(start + seg + seg,len); // 说当待排序的数组的个数不为2的幂次方时，在合并的过程当中就会出现end2大于len的情况。所以必须取较小值
            //if(end2 > len)
            //    end2 = len;
            while(start1 < end1 && start2 < end2)
            {
                if(vec[start1] < vec[start2])
                    vecTemp[index++] = vec[start1++];
                else 
                    vecTemp[index++] = vec[start2++];
            }
            //while(start1 < end1 && start2 < end2)
            //{
            //    vecTemp[index++] = vec[start1] < vec[start2] ? vec[start1++] : vec[start2++];
            //}
            while(start1 < end1)
                vecTemp[index++] = vec[start1++];
            while(start2 < end2)
                vecTemp[index++] = vec[start2++];
        }
        swap(vec,vecTemp);
    }
}

int main()
{
    int num;
    cin >> num;

    vector<int> vec;
    int temp;
    for(int i = 0; i < num; i++)
    {
        cin >> temp;
        vec.push_back(temp);
    }

    merge_sort(vec);

    for(vector<int>::iterator it = vec.begin(); it != vec.end(); ++it)
    {
        cout << *it << " ";
    }
    cout << endl;

    return 0;
}
